<template>
  <div
    class="card"
    :class="{
      'with-padding': padding,
      'with-margin': marginBottom,
    }"
  >
    <div
      v-if="title"
      class="card-header"
      :class="{ 'with-spacing': contentPadding }"
    >
      <h2 class="card-title">{{ title }}</h2>
      <slot name="actions"></slot>
    </div>
    <div class="card-content" :class="{ 'with-spacing': contentPadding }">
      <slot></slot>
    </div>
  </div>
</template>

<script setup lang="ts">
defineProps<{
  title?: string;
  padding?: boolean;
  marginBottom?: boolean;
  contentPadding?: boolean;
}>();
</script>

<style scoped>
.card {
  background-color: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease-in-out;
}

.card:hover {
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -2px rgba(0, 0, 0, 0.1);
}

.card.with-padding {
  padding: 24px;
}

.card.with-margin {
  margin-bottom: 24px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header.with-spacing {
  margin-bottom: 16px;
}

.card-title {
  font-size: 20px;
  font-weight: 700;
  color: #111827;
}

.card-content.with-spacing {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 响应式调整 */
@media (max-width: 640px) {
  .card.with-padding {
    padding: 16px;
  }

  .card-title {
    font-size: 18px;
  }

  .card-header.with-spacing {
    margin-bottom: 12px;
  }

  .card-content.with-spacing {
    gap: 12px;
  }
}
</style>
